package com.example.chat.controller;

import com.example.chat.pojo.dto.MessageDTO;
import com.example.chat.pojo.bo.Message;
import com.example.chat.pojo.res.ResModel;
import com.example.chat.service.MessageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 林邵晨
 * @since 2023-07-28
 */
@RestController
@RequestMapping("/chat/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @ApiOperation("发送消息")
    @PostMapping(value = "/send",produces = "application/json")
    public ResModel sendMessage(@RequestBody Message message){
        return messageService.sendMessage(message);
    }

    @ApiOperation("查询聊天消息")
    @PostMapping("/list")
    public ResModel getChatMsgList(@RequestBody Message message){
        return messageService.getChatMsgList(message);
    }

    @ApiOperation("修改聊天类型")
    @PostMapping("/type")
    public ResModel updateMsgType(@RequestBody MessageDTO message){
        return messageService.updateMsgType(message);
    }
}
